package org.idontknow.blocks;

class PileOnto extends Command {

  PileOnto(Block _from, Block _to) {
    super(_from, _to);
  }

  public void execute() {
	  log.info("Begin of \"PileOnto\" command");
    log.info("Returning blocks upon block " + blockTo.getValue() + "...");
    cleanTo();
    int idStackFrom = blockFrom.getStackId();
    int posStackFrom = blockFrom.getPosInStack();
    int idStackTo = blockTo.getStackId();
    log.info("Moving blocks...");
    this.moveBlocksOver(idStackFrom, idStackTo, stackFrom.getNbBlocksUpon(posStackFrom)+1);
    System.out.println("-------- Command: pile " + blockFrom.getValue() + " onto " + blockTo.getValue() + " --------");
    printStacks();
    log.info("End of \"PileOnto\" command\n\n----------------------------------------");
  }
}
